const taskColumns = {
    operation:[],
    columns:[
        {
            type: 'selection'
        },
        {
            title: '名称',
            key: 'name',
            width: 300
        },
        // {
        //     title: '简介',
        //     width: 300,
        //     key: 'describe'
        // },
        {
            title: '难易程度',
            key: 'difficulty'
        },
        {
            title: '项目题库题数',
            key: 'questions_number',
        },
        {
            title: '任务题数',
            key: 'questions',
            render(row) {
                if ('task_questions' in row) {
                    return row.task_questions.length;
                }
            }
        },
        {
            title: '操作',
            align: "left",
            titleAlign: 'center',
            width: 300,
            key: 'actions',
            render(row) {
                // 操作列表
                let array = {
                    edit: '修改详情',
                    del: '删除',
                }
                // 判断是项目还是任务
                if (row.type === '任务') {
                    // array.details = '详情'
                    array.deactivate = '启/停用'
                } else {
                    array.add = '新增任务'
                }
                let list = [];
                for (let key in array) {
                    list.push(
                        h(
                            'span',
                            {
                                class: 'span-button pointer',
                                onClick: () => taskColumns.operation[key](row)
                            },
                            {default: () => array[key]}
                        )
                    )
                }
                return list
            }
        }
    ]
}
export {taskColumns}